package com.cg.controller;

import com.cg.dto.DictionaryDto;
import com.cg.dto.DictionaryPageDto;
import com.cg.dto.Result;
import com.cg.dto.ResultUtils;
import com.cg.entity.DictionaryType;
import com.cg.service.DictionaryTypeService;
import com.cg.vo.DictionaryVo;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (DictionaryType)表控制层
 *
 * @author chengong
 * @since 2023-12-01 10:25:11
 */
@RestController
@RequestMapping("/type")
public class DictionaryTypeController {
    /**
     * 服务对象
     */
    @Resource
    private DictionaryTypeService dictionaryTypeService;

    /**
     * 查询全部Type
     * @return
     */
    @PostMapping("/queryTypeAll")
    public Result<List<DictionaryType>> queryTypeAll(){
        return ResultUtils.returnDataSuccess(dictionaryTypeService.queryTypeAll());
    }


    /**
     * 新增
     */
    @PostMapping("/createDictionaryType")
    public Result createDictionaryType(@RequestBody DictionaryDto dictionaryDto){
        return ResultUtils.returnDataSuccess(dictionaryTypeService.createDictionaryType(dictionaryDto));
    }


    /**
     * 查询数据字典表
     */
    @PostMapping("/queryDictionary")
    public Result<Map<String,Object>> queryDictionary(@RequestBody DictionaryPageDto dictionaryPageDto){
        PageInfo<DictionaryVo> pageInfo = dictionaryTypeService.queryDictionary(dictionaryPageDto);
        Map<String,Object> map = new HashMap<>();
        map.put("pageInfo",pageInfo);
        return ResultUtils.returnDataSuccess(map);
    }

}

